********************************************************************************
********************************************************************************
* to obtain the dataset 
*	1) with fips attached
*	2) append all emission sources
********************************************************************************
********************************************************************************
clear all
version 11
set more off

global root "~\APEEP_2008\results"
cd $root


****************************
* attach fips with md - area
****************************
insheet using .\APEEP_results_output\2008_PM_MD_A.csv, nonames comma clear
ren v1 md_nh3
ren v2 md_pm25
ren v3 md_nox
ren v4 md_so2
ren v5 md_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren a fips
keep md_nh3- fips_running fips

compress
saveold .\Stata_working\data_md_with_fips_area, version(11) replace


****************************
* attach fips with md - low
****************************
insheet using .\APEEP_results_output\2008_PM_MD_L.csv, nonames comma clear
ren v1 md_nh3
ren v2 md_pm25
ren v3 md_nox
ren v4 md_so2
ren v5 md_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren l fips
keep md_nh3- fips_running fips

compress
saveold .\Stata_working\data_md_with_fips_low, version(11) replace


****************************
* attach fips with md - med
****************************
insheet using .\APEEP_results_output\2008_PM_MD_M.csv, nonames comma clear
ren v1 md_nh3
ren v2 md_pm25
ren v3 md_nox
ren v4 md_so2
ren v5 md_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren m fips
keep md_nh3- fips_running fips

compress
saveold .\Stata_working\data_md_with_fips_med, version(11) replace


****************************
* attach fips with md - T1
****************************
insheet using .\APEEP_results_output\2008_PM_MD_T1.csv, nonames comma clear
ren v1 md_nh3
ren v2 md_pm25
ren v3 md_nox
ren v4 md_so2
ren v5 md_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren t1 fips
keep md_nh3- fips_running fips
drop if fips==.

compress
saveold .\Stata_working\data_md_with_fips_t1, version(11) replace


****************************
* attach fips with md - T2
****************************
insheet using .\APEEP_results_output\2008_PM_MD_T2.csv, nonames comma clear
ren v1 md_nh3
ren v2 md_pm25
ren v3 md_nox
ren v4 md_so2
ren v5 md_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren t2 fips
keep md_nh3- fips_running fips
drop if fips==.

compress
saveold .\Stata_working\data_md_with_fips_t2, version(11) replace


****************************
* append all the datasets
****************************
use .\Stata_working\data_md_with_fips_area, clear
append using .\Stata_working\data_md_with_fips_low ///
			 .\Stata_working\data_md_with_fips_med ///
			 .\Stata_working\data_md_with_fips_t1 ///
			 .\Stata_working\data_md_with_fips_t2, nolabel
*
gen apeep_results_running=_n
ren fips fips_md

compress
saveold .\Stata_working\data_md_with_fips_all_appended, version(11) replace


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	